<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  
  <title>CentOS下yum安装LAMP | 上海科鹄网络科技有限公司</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="description" content="CentOS下yum安装LAMP">
<meta property="og:type" content="article">
<meta property="og:title" content="CentOS下yum安装LAMP">
<meta property="og:url" content="http://ikohoo.com/blog/2017/09/19/centos-lamp/index.html">
<meta property="og:site_name" content="上海科鹄网络科技有限公司">
<meta property="og:description" content="CentOS下yum安装LAMP">
<meta property="og:updated_time" content="2017-09-19T05:49:35.070Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="CentOS下yum安装LAMP">
<meta name="twitter:description" content="CentOS下yum安装LAMP">
  
    <link rel="alternate" href="/atom.xml" title="上海科鹄网络科技有限公司" type="application/atom+xml">
  
  
    <link rel="icon" href="/favicon.png">
  
  
    <link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
  
  <link rel="stylesheet" href="/blog/css/style.css">
  

</head>

<body>
  <div id="container">
    <div id="wrap">
      <header id="header">
  <div id="banner"></div>
  <div id="header-outer" class="outer">
    <div id="header-title" class="inner">
      <h1 id="logo-wrap">
        <a href="/blog/" id="logo">上海科鹄网络科技有限公司</a>
      </h1>
      
        <h2 id="subtitle-wrap">
          <a href="/blog/" id="subtitle">国内领先的云计算和大数据解决方案咨询服务商</a>
        </h2>
      
    </div>
    <div id="header-inner" class="inner">
      <nav id="main-nav">
        <a id="main-nav-toggle" class="nav-icon"></a>
        
          <a class="main-nav-link" href="/blog/">Home</a>
        
          <a class="main-nav-link" href="/blog/archives">Archives</a>
        
      </nav>
      <nav id="sub-nav">
        
          <a id="nav-rss-link" class="nav-icon" href="/atom.xml" title="Flux RSS"></a>
        
        <a id="nav-search-btn" class="nav-icon" title="Rechercher"></a>
      </nav>
      <div id="search-form-wrap">
        <form action="//google.com/search" method="get" accept-charset="UTF-8" class="search-form"><input type="search" name="q" class="search-form-input" placeholder="Search"><button type="submit" class="search-form-submit">&#xF002;</button><input type="hidden" name="sitesearch" value="http://ikohoo.com/blog"></form>
      </div>
    </div>
  </div>
</header>
      <div class="outer">
        <section id="main"><article id="post-centos-lamp" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/blog/2017/09/19/centos-lamp/" class="article-date">
  <time datetime="2017-09-19T05:45:51.000Z" itemprop="datePublished">2017-09-19</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 class="article-title" itemprop="name">
      CentOS下yum安装LAMP
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <p>CentOS下yum安装LAMP</p>
<a id="more"></a>
<h1 id="1-用yum安装Apache-Mysql-PHP"><a href="#1-用yum安装Apache-Mysql-PHP" class="headerlink" title="1. 用yum安装Apache,Mysql,PHP."></a>1. 用yum安装Apache,Mysql,PHP.</h1><h2 id="1-1安装Apache"><a href="#1-1安装Apache" class="headerlink" title="1.1安装Apache"></a>1.1安装Apache</h2><p>yum install httpd httpd-devel<br>安装完成后，用/etc/init.d/httpd start 启动apache<br>设为开机启动:chkconfig httpd on </p>
<h2 id="1-2-安装mysql"><a href="#1-2-安装mysql" class="headerlink" title="1.2 安装mysql"></a>1.2 安装mysql</h2><p>1.2.1 yum install mysql mysql-server mysql-devel<br>同样，完成后，用/etc/init.d/mysqld start 启动mysql<br>1.2.2 设置mysql密码<br>mysql&gt;; USE mysql;<br>mysql&gt;; UPDATE user SET Password=PASSWORD(‘newpassword’) WHERE user=’root’;<br>mysql&gt;; FLUSH PRIVILEGES;<br>1.2.3 允许远程登录<br>mysql -u root -p<br>Enter Password: <your new="" password=""><br>mysql&gt;GRANT ALL PRIVILEGES ON <em>.</em> TO ‘用户名’@’%’ IDENTIFIED BY ‘密码’ WITH GRANT OPTION;<br>完成后就能用mysql-front远程管理mysql了。<br>1.2.4 设为开机启动<br>chkconfig mysqld on </your></p>
<h1 id="2-安装php"><a href="#2-安装php" class="headerlink" title="2. 安装php"></a>2. 安装php</h1><p>yum install php php-mysql php-common php-gd php-mbstring php-mcrypt php-devel php-xml<br>/etc/init.d/httpd start </p>
<h1 id="3-测试一下"><a href="#3-测试一下" class="headerlink" title="3. 测试一下"></a>3. 测试一下</h1><h2 id="3-1-编写测试网页"><a href="#3-1-编写测试网页" class="headerlink" title="3.1 编写测试网页"></a>3.1 编写测试网页</h2><p>在/var/www/html/新建个test.php文件，将以下内容写入，然后保存。<br>&lt;?<br>phpinfo();<br>?&gt; </p>
<h2 id="3-2-防火墙配置"><a href="#3-2-防火墙配置" class="headerlink" title="3.2 防火墙配置"></a>3.2 防火墙配置</h2><p>a.添加.允许访问端口{21: ftp, 80: http}.<br>iptables -I RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 21 -j ACCEPT<br>iptables -I RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT<br>b.关闭防火墙{不推荐}.<br>service iptables stop<br>c.重置加载防火墙<br>service iptables restart </p>
<h2 id="3-3-测试"><a href="#3-3-测试" class="headerlink" title="3.3 测试"></a>3.3 测试</h2><p>然后在客户端浏览器里打开<a href="http://serverip/test.php，若能成功显示，则表示安装成功。" target="_blank" rel="external">http://serverip/test.php，若能成功显示，则表示安装成功。</a><br>至此，安装完毕。感慨，yum真是太好用了。<br>CentOS 打开防火墙80端口</p>
<h1 id="防火墙设置"><a href="#防火墙设置" class="headerlink" title="防火墙设置"></a>防火墙设置</h1><p>注意：有时安装好可能无法访问，需要打开80端口<br>很大的原因是防火墙：<br>通过/etc/init.d/iptables status命令查询是否有打开80端口，如果没有可通过两种方式处理：<br>1.修改vi /etc/sysconfig/iptables命令添加使防火墙开放80端口<br>-A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT<br>2.关闭防火墙<br>/etc/init.d/iptables stop </p>
<p>#start 开启 </p>
<p>#restart 重启<br>永久性关闭防火墙chkconfig –level 35 iptables off</p>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://ikohoo.com/blog/2017/09/19/centos-lamp/" data-id="cja3l1mrc00144stk84qeba2n" class="article-share-link">Partager</a>
      
      
    </footer>
  </div>
  
    
<nav id="article-nav">
  
    <a href="/blog/2017/11/17/build-warehouse/" id="article-nav-newer" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Récent</strong>
      <div class="article-nav-title">
        
          搭建数据仓库的流程简介
        
      </div>
    </a>
  
  
    <a href="/blog/2017/09/19/mysql-user/" id="article-nav-older" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Ancien</strong>
      <div class="article-nav-title">Mysql用户和权限管理</div>
    </a>
  
</nav>

  
</article>

</section>
        
          <aside id="sidebar">
  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Catégories</h3>
    <div class="widget">
      <ul class="category-list"><li class="category-list-item"><a class="category-list-link" href="/blog/categories/AI/">AI</a></li><li class="category-list-item"><a class="category-list-link" href="/blog/categories/Big-Data/">Big Data</a></li><li class="category-list-item"><a class="category-list-link" href="/blog/categories/CloudCompute/">CloudCompute</a></li><li class="category-list-item"><a class="category-list-link" href="/blog/categories/Efficiency/">Efficiency</a></li><li class="category-list-item"><a class="category-list-link" href="/blog/categories/RESTful-API/">RESTful API</a></li><li class="category-list-item"><a class="category-list-link" href="/blog/categories/skills/">skills</a></li><li class="category-list-item"><a class="category-list-link" href="/blog/categories/数据仓库/">数据仓库</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Mot-clés</h3>
    <div class="widget">
      <ul class="tag-list"><li class="tag-list-item"><a class="tag-list-link" href="/blog/tags/AI/">AI</a></li><li class="tag-list-item"><a class="tag-list-link" href="/blog/tags/Big-Data/">Big Data</a></li><li class="tag-list-item"><a class="tag-list-link" href="/blog/tags/CloudCompute/">CloudCompute</a></li><li class="tag-list-item"><a class="tag-list-link" href="/blog/tags/CloudStack/">CloudStack</a></li><li class="tag-list-item"><a class="tag-list-link" href="/blog/tags/Docker/">Docker</a></li><li class="tag-list-item"><a class="tag-list-link" href="/blog/tags/Efficiency/">Efficiency</a></li><li class="tag-list-item"><a class="tag-list-link" href="/blog/tags/Eucalyptus/">Eucalyptus</a></li><li class="tag-list-item"><a class="tag-list-link" href="/blog/tags/FusionCloud/">FusionCloud</a></li><li class="tag-list-item"><a class="tag-list-link" href="/blog/tags/HBase/">HBase</a></li><li class="tag-list-item"><a class="tag-list-link" href="/blog/tags/Hadoop/">Hadoop</a></li><li class="tag-list-item"><a class="tag-list-link" href="/blog/tags/Hive/">Hive</a></li><li class="tag-list-item"><a class="tag-list-link" href="/blog/tags/Openstack/">Openstack</a></li><li class="tag-list-item"><a class="tag-list-link" href="/blog/tags/RESTful/">RESTful</a></li><li class="tag-list-item"><a class="tag-list-link" href="/blog/tags/Resource/">Resource</a></li><li class="tag-list-item"><a class="tag-list-link" href="/blog/tags/Slack/">Slack</a></li><li class="tag-list-item"><a class="tag-list-link" href="/blog/tags/Spark/">Spark</a></li><li class="tag-list-item"><a class="tag-list-link" href="/blog/tags/Team-Management/">Team Management</a></li><li class="tag-list-item"><a class="tag-list-link" href="/blog/tags/Wiki/">Wiki</a></li><li class="tag-list-item"><a class="tag-list-link" href="/blog/tags/cloudcompute/">cloudcompute</a></li><li class="tag-list-item"><a class="tag-list-link" href="/blog/tags/lucene/">lucene</a></li><li class="tag-list-item"><a class="tag-list-link" href="/blog/tags/markdown/">markdown</a></li><li class="tag-list-item"><a class="tag-list-link" href="/blog/tags/solr/">solr</a></li><li class="tag-list-item"><a class="tag-list-link" href="/blog/tags/startup/">startup</a></li><li class="tag-list-item"><a class="tag-list-link" href="/blog/tags/数据仓库/">数据仓库</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Nuage de mot-clés</h3>
    <div class="widget tagcloud">
      <a href="/blog/tags/AI/" style="font-size: 10px;">AI</a> <a href="/blog/tags/Big-Data/" style="font-size: 18px;">Big Data</a> <a href="/blog/tags/CloudCompute/" style="font-size: 16px;">CloudCompute</a> <a href="/blog/tags/CloudStack/" style="font-size: 10px;">CloudStack</a> <a href="/blog/tags/Docker/" style="font-size: 10px;">Docker</a> <a href="/blog/tags/Efficiency/" style="font-size: 14px;">Efficiency</a> <a href="/blog/tags/Eucalyptus/" style="font-size: 10px;">Eucalyptus</a> <a href="/blog/tags/FusionCloud/" style="font-size: 10px;">FusionCloud</a> <a href="/blog/tags/HBase/" style="font-size: 10px;">HBase</a> <a href="/blog/tags/Hadoop/" style="font-size: 10px;">Hadoop</a> <a href="/blog/tags/Hive/" style="font-size: 10px;">Hive</a> <a href="/blog/tags/Openstack/" style="font-size: 10px;">Openstack</a> <a href="/blog/tags/RESTful/" style="font-size: 12px;">RESTful</a> <a href="/blog/tags/Resource/" style="font-size: 10px;">Resource</a> <a href="/blog/tags/Slack/" style="font-size: 12px;">Slack</a> <a href="/blog/tags/Spark/" style="font-size: 10px;">Spark</a> <a href="/blog/tags/Team-Management/" style="font-size: 14px;">Team Management</a> <a href="/blog/tags/Wiki/" style="font-size: 20px;">Wiki</a> <a href="/blog/tags/cloudcompute/" style="font-size: 10px;">cloudcompute</a> <a href="/blog/tags/lucene/" style="font-size: 10px;">lucene</a> <a href="/blog/tags/markdown/" style="font-size: 10px;">markdown</a> <a href="/blog/tags/solr/" style="font-size: 10px;">solr</a> <a href="/blog/tags/startup/" style="font-size: 14px;">startup</a> <a href="/blog/tags/数据仓库/" style="font-size: 10px;">数据仓库</a>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Archives</h3>
    <div class="widget">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/blog/archives/2017/11/">十一月 2017</a></li><li class="archive-list-item"><a class="archive-list-link" href="/blog/archives/2017/09/">九月 2017</a></li><li class="archive-list-item"><a class="archive-list-link" href="/blog/archives/2017/07/">七月 2017</a></li><li class="archive-list-item"><a class="archive-list-link" href="/blog/archives/2017/06/">六月 2017</a></li><li class="archive-list-item"><a class="archive-list-link" href="/blog/archives/2017/05/">五月 2017</a></li><li class="archive-list-item"><a class="archive-list-link" href="/blog/archives/2017/02/">二月 2017</a></li><li class="archive-list-item"><a class="archive-list-link" href="/blog/archives/2016/06/">六月 2016</a></li><li class="archive-list-item"><a class="archive-list-link" href="/blog/archives/2016/05/">五月 2016</a></li><li class="archive-list-item"><a class="archive-list-link" href="/blog/archives/2016/03/">三月 2016</a></li><li class="archive-list-item"><a class="archive-list-link" href="/blog/archives/2016/02/">二月 2016</a></li><li class="archive-list-item"><a class="archive-list-link" href="/blog/archives/2015/12/">十二月 2015</a></li><li class="archive-list-item"><a class="archive-list-link" href="/blog/archives/2015/11/">十一月 2015</a></li><li class="archive-list-item"><a class="archive-list-link" href="/blog/archives/2015/10/">十月 2015</a></li><li class="archive-list-item"><a class="archive-list-link" href="/blog/archives/2015/09/">九月 2015</a></li><li class="archive-list-item"><a class="archive-list-link" href="/blog/archives/2015/08/">八月 2015</a></li><li class="archive-list-item"><a class="archive-list-link" href="/blog/archives/2015/06/">六月 2015</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Articles récents</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="/blog/2017/11/17/build-warehouse/">搭建数据仓库的流程简介</a>
          </li>
        
          <li>
            <a href="/blog/2017/09/19/centos-lamp/">CentOS下yum安装LAMP</a>
          </li>
        
          <li>
            <a href="/blog/2017/09/19/mysql-user/">Mysql用户和权限管理</a>
          </li>
        
          <li>
            <a href="/blog/2017/09/18/unicode/">Unicode(UTF-8, UTF-16)令人混淆的概念</a>
          </li>
        
          <li>
            <a href="/blog/2017/09/07/restful-api-practice/">RESTful API 设计最佳实践</a>
          </li>
        
      </ul>
    </div>
  </div>

  
</aside>
        
      </div>
      <footer id="footer">
  
  <div class="outer">
    <div id="footer-info" class="inner">
      &copy; 2017 Leo.Liu<br>
      Propulsé by <a href="http://hexo.io/" target="_blank">Hexo</a>
    </div>
  </div>
</footer>
    </div>
    <nav id="mobile-nav">
  
    <a href="/blog/" class="mobile-nav-link">Home</a>
  
    <a href="/blog/archives" class="mobile-nav-link">Archives</a>
  
</nav>
    

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>


  <link rel="stylesheet" href="/blog/fancybox/jquery.fancybox.css">
  <script src="/blog/fancybox/jquery.fancybox.pack.js"></script>


<script src="/blog/js/script.js"></script>

  </div>
</body>
</html>